home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_02 / 9n02118b < prev    next >
Text File  |  1990-12-15  |  484b  |  28 lines

  1.  
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. int comp(unsigned char **, unsigned char **);
  9. unsigned char *list[] = { "cat", "car", "cab",
  10.                           "cap", "can" };
  11.  
  12. main()
  13.      {
  14.      int x;
  15.  
  16.      qsort(list, 5, sizeof(unsigned char *), comp);
  17.      for (x = 0; x < 5; x++)
  18.           printf("%s\n", list[x]);
  19.      return 0;
  20.      }
  21.  
  22. int comp(unsigned char **a, unsigned char **b)
  23.      {
  24.      return strcmp(*a, *b);
  25.       }
  26.  
  27.  
  28.